<template>
	<view class="model" v-for="item in themes" :key="item.id" @click="toChat(item)">
		<view class="item">
			<view class="icon">
				<image :src="$request.baseUrl + item.img" mode="aspectFill"></image>
			</view>
			<view class="info">
				<view class="title">{{ item.tname }}</view>
				<view class="content">{{ item.detail }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				themes: []
			}
		},
		onLoad() {
			this.getThemes()
		},
		methods: {
			getThemes() {
				this.$request.get('/mini/chat/themeList').then(res => {
					if (res.code === 200) {
						this.themes = res.data
					} else {
						uni.showToast({
							title: res.msg,
							duration: 2000,
							icon: 'none'
						})
					}
				})
			},
			toChat(item) {
				uni.navigateTo({
					url: '/pages/chat/chat?tid=' + item.id + '&uid=' + uni.getStorageSync('user').id + '&tname=' + item.tname
				})
			}
		}
	}
</script>

<style scoped>
	.model {
		width: 678rpx;
		margin: 10rpx auto;
		margin-top: 20rpx;
		padding: 10rpx 0;
		border-radius: 20rpx;
		box-shadow: 0rpx 0rpx 16rpx  rgba(0, 0, 0, 0.08);
	}
	.model .item {
		width: 678rpx;
		padding: 15rpx 0;
		display: flex;
		align-items: center;
	}
	
	.icon {
		width: 180rpx;
		height: 180rpx;
		margin: 0 20rpx;
		margin-right: 20rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.icon image {
		width: 100%;
		height: 100%;
		border-radius: 20rpx;
	}
	.forum {
		background-color: #197368;
	}
	
	.info {
		width: 440rpx;
		opacity: 1;
		display: flex;
		flex-direction: column;
		justify-content: center;
	} 
 	.info .title {
		font-size: 32rpx;
		font-weight: 400;
		letter-spacing: 0rpx;
		line-height: 47.36rpx;
		color: #4E4E4E;
		text-align: left;
		vertical-align: top;
	}
	.info .content {
		max-height: 120rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 3;
		-webkit-box-orient: vertical;
		font-size: 28rpx;
		font-weight: 400;
		color: #B9BAC7;
	}
</style>
